<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@page import="com.lmpop.trade.backupDB.*" %>
<%@page import="java.util.*" %>
<%@page import="com.lmpop.frame.util.Config" %>
<%@ page import="java.io.*"%>

<%
/***********************基本信息***********************/
Config cfg = new Config();
cfg.init();
String dbName = cfg.getString("mysqlbase.sid");
String root_path = cfg.getString("rootpath");
Backup backup = new Backup();

int bakfileSize=0;

ArrayList bakfileList = DataMgr.getBakInfo(root_path + cfg.getString("database_backup_files_path"));
if(bakfileList != null && bakfileList.size() > 0){
	bakfileSize = bakfileList.size();
}

%>
<html>
	<head>
		<title>数据还原</title>
		<link rel="stylesheet" rev="stylesheet" href="/style/admin.css" type="text/css" />
		<link rel="stylesheet" rev="stylesheet" href="/style/content.css" type="text/css" />
		<script type='text/javascript' src='/js/jquery.js'></script>
		<script type="text/javascript">
			function restore(){//恢复数据库,每次只能恢复一个文件
 
			    var itemradio = document.getElementsByName("itemradio"); 
			    var itemvalue = '';  
			    for(i=0;i<itemradio.length;i++)   
			    {   
			      	if(itemradio[i].checked){
			      		itemvalue = itemradio[i].value;
			      	}
			  	} 
			  	if(itemvalue==''){
			  		alert('请选择备份的数据库！');
			  		return false;
			  	}  
				document.getElementById('backup_dbname').value = itemvalue;
				document.submitForm.submit();
			}

		</script>

	</head>
	
	<form id="submitForm" name="submitForm" method="post" action="/doTradeReg.do" target="_self">
	
	<body>
		<div id="main">
			<div id="contentfloat">
				<div id="content">
					<div class="right_title">
						数据库恢复<%=bakfileSize%>
					</div>
					<br>
					
					<table cellspacing="0" cellpadding="4" width="100%" align="center" border="0" class="table_title">
						
						<tr>
							<th width="5%">
								选择
							</th>
							<th width="20%">
								文件名
							</th>
							<th width="20%">
								大小
							</th>
							<th width="30%">
								操作
							</th>
						</tr>

						<%
								for(int i=0;i<bakfileSize;i++){
									DataFile dataFile = (DataFile)bakfileList.get(i);
									String fileName = dataFile.getFileName();
									long fileSize = dataFile.getFileSize();
						%>
						<tr id="" onMouseOver="changeColor(this,1)" onmouseout="changeColor(this,2)">
							<td>
								<input type="radio" name="itemradio" value="<%=fileName%>" />
							</td>
							<td>
								<%=fileName%> 
							</td>
							<td>
								<%=fileSize%> KB
							</td>
							<td> 
								<a href="delBakFile.jsp?file_name=<%=fileName%>">删除</a>
							</td>
						</tr>
						<%}%>
						<tr>
							<th colspan="4" align="center">
								<input type="button" value="开始还原数据" class="submitButton" onclick="restore()"/>&nbsp;&nbsp;
								<input type="button" value="返回" class="submitButton" onclick="javascript:window.location.href='/trade/manager/backupDb/index.jsp'"/>
							</th>
						</tr>
					</table>
				</div>
				<div></div>
			</div>
			<!--//right-->
			<!--隐藏提交-->
				<input type="hidden" id="backup_dbname" name="backup_dbname" value="">
				<input type="hidden" id="trade_type_code" name="trade_type_code" value="0015">
			
			
		</div>
		
		</form>
		
	</body>
</html>
